package cn.anecansaitin.whimsy.common.network;

import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.neoforge.network.PacketDistributor;

public final class NetworkHelper {
    public static void toServerPlayer(CustomPacketPayload... payloads) {
        send(PacketDistributor.SERVER.noArg(), payloads);
    }

    public static void toServerPlayer(CustomPacketPayload payloads) {
        send(PacketDistributor.SERVER.noArg(), payloads);
    }

    public static void toClientPlayer(ServerPlayer player, CustomPacketPayload... payloads) {
        send(PacketDistributor.PLAYER.with(player), payloads);
    }

    public static void toClientPlayer(ServerPlayer player, CustomPacketPayload payloads) {
        send(PacketDistributor.PLAYER.with(player), payloads);
    }

    public static void send(PacketDistributor.PacketTarget target, CustomPacketPayload packet) {
        target.send(packet);
    }

    public static void send(PacketDistributor.PacketTarget target, CustomPacketPayload... packet) {
        target.send(packet);
    }
}
